package latch;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class CountDownLatchDemo {

	public static void main(String[] args) {
		ExecutorService executor = Executors.newCachedThreadPool();
		CountDownLatch latch = new CountDownLatch(3);
		WorkerThread w1 = new 	WorkerThread(latch,"David");
		WorkerThread w2 = new WorkerThread(latch,"Jim");
		WorkerThread w3 = new WorkerThread(latch,"Lily");
		CompetentThread boss = new CompetentThread(latch);
		executor.execute(w3);
		executor.execute(w2);
		executor.execute(w1);
		executor.execute(boss);
		executor.shutdown();
	}

}

